package com.weige.conver.service;

import com.weige.conver.entity.EnvObject;
import com.weige.conver.entity.ReceiveMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service
public class DeviceService {

    private ConfigService configService = new ConfigService();

    private Map<String,String> TYPE_Map = configService.getTypeData();

    public List<EnvObject> getDataList(Map<String, ReceiveMessage> map){
        List<EnvObject> envObjectList = new ArrayList<>();
        map.forEach((k, v) -> {
            ReceiveMessage receiveMessage = v;
            EnvObject envObject = new EnvObject();
            envObject.setObjectId(receiveMessage.getDevId());
            envObject.setObjectName(receiveMessage.getDevName());
            envObject.setObjectType(TYPE_Map.get(String.valueOf(receiveMessage.getType())));
            envObject.setObjectLevel(2);
            envObject.setParentObeject("");
            envObjectList.add(envObject);
        });
        return envObjectList;
    }
}
